import java.util.Scanner;

public class Main {
    /*解题思路：先输入所需要的数据，用两个数组arra和arrb分别放置a和b供应商的商品单价
    * 然后比较网购费用与数组arra/arrb中所有元素之和*/
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int arra[] = new int[n];
        int arrb[] = new int[n];
        for (int i = 0; i < n; i++) {
            arra[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            arrb[i] = sc.nextInt();
        }
        //开始比较
        int a = 0;
        int b = 0;
        for (int i = 0; i < n; i++) {
            a += arra[i];
            b += arrb[i];
        }
        int min = Min(x,a,b);
        System.out.println(min);
    }

    private static int Min(int x, int a, int b) {
        int min = x;
        if (a < min){
            min = a;
        }else if (b < min){
            min = b;
        }
        return min;
    }
}
